import QtQuick 2.3

Rectangle {
    width: 400
    height: 400

    property real m_angle: 0
    property string m_strTxt: '0'

    Timer {
        id: timerAngle
        repeat: true
        interval: 100
        onTriggered: {
            m_angle += Math.PI/90
            if (m_angle >= Math.PI*2) {
                m_angle = 0
            }

            //print("m_angle: ", m_angle)
            ca.requestPaint()

            var tmp = m_strTxt - ''
            tmp += 1
            if (tmp >= 180) {
                tmp = 0
            }
            m_strTxt = tmp + ''
        }
    }

    Canvas {
        id: ca
        anchors.fill: parent
        onPaint: {
            var ctx = getContext("2d");
            ctx.reset();

            var centreX = width / 2;
            var centreY = height / 2;

            ctx.beginPath()
            ctx.strokeStyle = "blue";
            ctx.arc(centreX, centreY, width / 4, 0, 2*Math.PI, false);
            ctx.lineWidth = 6
            ctx.stroke();

            ctx.beginPath()
            ctx.strokeStyle = "blue";
            ctx.arc(centreX, centreY, width / 4-8, -Math.PI/2, -Math.PI/2+m_angle, false);
            ctx.lineWidth = 26
            ctx.stroke();
        }


        Component.onCompleted: timerAngle.start()
    }


    Text {
        id: txt
        text: m_strTxt
        anchors.centerIn: parent
        font.pixelSize: 40
        font.bold: true
    }
}